from typing import List


class Solution:
    def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
        #选出最小长度
        n1 = nums1 if len(nums1) < len(nums2) else nums2
        # 选出最大长度
        n2 = nums2 if len(nums1) < len(nums2) else nums1
        n3 = list()
        for i in n1:
            if i in n2:
                n3.append(i)
                n2.remove(i)
        return n3




if __name__ == '__main__':
    nums1 = [1,2,2,1]
    nums2 = [2,2]
    solution = Solution()
    val = solution.intersect(nums1,nums2)
    print(val)
